package www.openteam.com.presenter;


import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.Worker;
import www.openteam.com.contract.business.other.PSearchContract;
import www.openteam.com.model.business.other.PSearchModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.business.other.HZRBPSearchFragment;
import www.openteam.com.ui.business.other.PSearchFragment;

/**
 * Created by kylin on 2017/5/3.
 */

public class HZRBPSearchPresenter extends BasePresenter<HZRBPSearchFragment> implements
        PSearchContract.PSearchPresenter {


    @Override
    public HashMap<String, IModel> getiModelMap() {

        return loadModelMap(new PSearchModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("pSearch", models[0]);
        return hashMap;
    }

    @Override
    public void findWorker(String code) {
        ((PSearchModel) getiModelMap().get("pSearch")).findWorker(code, new PSearchModel
                .PSearchOnListener() {
            @Override
            public void suceessPInfo(Worker worker) {
                getIView().queryPSuccess(worker);
            }

            @Override
            public void failPInfo(String error) {
                getIView().queryPFail(error);
            }


        });
    }
}
